#include<iostream>
#include"EquationSolver.h"

  class myf_1 : public Function
  {
  public:
    double operator()(double x){
      return x-tan(x);
    }
    double diff(double x){
    double f;
    f = (this->operator()(x)-this->operator()(x-1e-8))/1e-8;
    return f;
  }
  };
int main(void){

  myf_1 f_1;
  Newton<myf_1> New_1(4.6, 20, f_1);
  Newton<myf_1> New_2(7.8, 20, f_1);
  double *R_1 = New_1.solve();
  double *R_2 = New_2.solve();
  std::cout<<"4.5附近根为："<<R_1[0]<<",迭代次数为"<<R_1[1]<<",误差为"<<f_1(R_1[0])<<std::endl;
  std::cout<<"*******************************************************"<<std::endl;
  std::cout<<"7.7附近根为："<<R_2[0]<<",迭代次数为"<<R_2[1]<<",误差为"<<f_1(R_2[0])<<std::endl;

}
